package com.xebia.eshop.web.config;

import java.io.IOException;
import java.util.Properties;

import javax.inject.Scope;
import javax.inject.Singleton;

import com.google.inject.Scopes;
import com.google.inject.name.Names;
import com.google.inject.servlet.ServletModule;
import com.xebia.eshop.services.books.BookService;
import com.xebia.eshop.services.books.impl.BookServiceImpl;
import com.xebia.eshop.utils.jsonclient.JSonClient;

public class GuiceServletModule extends ServletModule{
    @Override
    protected void configureServlets() {
    	
    	
    	Properties p = new Properties();
    	try {
			p.load(GuiceServletModule.class.getResourceAsStream("/config.properties"));
			System.out.println(p.getProperty("test"));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	Names.bindProperties(binder(), p);
    	bind(BookService.class).to(BookServiceImpl.class);
    	bind(JSonClient.class).in(Scopes.SINGLETON);;
//    	install(new GuiceRestModule());
          // serve("*.html").with(MyServlet.class);
    }
}
